Skip to content

Conversation

@jpouellet
Copy link

Otherwise update_current_git_vars gets called twice per prompt.

To confirm this is the case, do something like the following:

diff --git a/zshrc.sh b/zshrc.sh
index cdb8b4f..e758afb 100644
--- a/zshrc.sh
+++ b/zshrc.sh
@@ -30,6 +30,7 @@ function preexec_update_git_vars() {
 }

 function precmd_update_git_vars() {
+echo "### in precmd" > /dev/tty
     if [ -n "$__EXECUTED_GIT_COMMAND" ] || [ ! -n "$ZSH_THEME_GIT_PROMPT_CACHE" ]; then
         update_current_git_vars
         unset __EXECUTED_GIT_COMMAND
@@ -41,6 +42,7 @@ function chpwd_update_git_vars() {
 }

 function update_current_git_vars() {
+echo "### in update" > /dev/tty
     unset __CURRENT_GIT_STATUS

     if [[ "$GIT_PROMPT_EXECUTABLE" == "python" ]]; then

And then you will see:

$ cd /tmp/repo
### in update
### in precmd
### in update
### in precmd
### in update
(master|●2)  $ PS1='no-git-status $ '
### in precmd
### in update
no-git-status $ echo test
test
### in precmd
### in update
no-git-status $ PS1='$(git_super_status) $ '
### in precmd
### in update
### in precmd
### in update
(master|●2)  $ echo test 2
test 2
### in precmd
### in update
### in precmd
### in update
(master|●2)  $

Otherwise update_current_git_vars gets called twice per prompt.
@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling f2ea0ed on jpouellet:no_double_update into 7d480a9 on olivierverdier:master.

@jpouellet
Copy link
Author

It might actually be a better idea to update it in git_super_status and not in the precmd, that way if you remove $(git_super_status) from your prompt, you no longer waste time checking git things.

@tombh tombh mentioned this pull request Jun 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants